//
//  RNOLReferrerFormView.m
//  RongNiuOnline
//
//  Created by apple on 2018/4/23.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLReferrerFormView.h"

@interface RNOLReferrerFormView ()

@property (weak, nonatomic) IBOutlet UITextField *formTextField;
@property (nonatomic,copy) dispatch_block_t closeBlock;
@property (nonatomic,copy) dispatch_block_t commitBlock;
@end

@implementation RNOLReferrerFormView

- (void)awakeFromNib{
    [super awakeFromNib];
    ViewRadius(self, 15);
}

- (IBAction)closeAction:(UIButton *)sender {
    !self.closeBlock? : self.closeBlock();
}

- (IBAction)commitAction:(UIButton *)sender {
    !self.commitBlock? : self.commitBlock();
}

+ (void)showAlertReferrerFormConfigData:(void(^)(UITextField *textfield))callBackBlock{
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH -60 , 260)];
    ViewRadius(bgView, 15);
    bgView.backgroundColor = [UIColor clearColor];
    bgView.userInteractionEnabled = YES;
    
    RNOLReferrerFormView *formView = [RNOLReferrerFormView FromXIB];
    formView.frame = bgView.bounds;
    [bgView addSubview: formView];
    
    WGBCustomPopUpView *popup = [[WGBCustomPopUpView alloc] init];
    popup.animationType = WGBAlertAnimationTypeCenter;
    popup.contentView = bgView;
    [popup show];
    
    [formView setCloseBlock:^{
        [popup dismiss];
    }];
    
    @weakify(formView);
    [formView setCommitBlock:^{
        @strongify(formView);
        !callBackBlock? : callBackBlock(formView.formTextField);
        [popup dismiss];
    }];
}

@end
